home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3.iso / chapte21 / ex13.c < prev    next >
C/C++ Source or Header  |  1995-05-31  |  2KB  |  56 lines

  1. #include <genstub.c>
  2.  
  3. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  4. {
  5.    static TIME_ZONE_INFORMATION tziInit;
  6.  
  7.    switch (uMsg)
  8.    {
  9.          case WM_CREATE:
  10.                GetTimeZoneInformation( &tziInit );  // save time zone data
  11.                return (DefWindowProc(hWnd, uMsg, wParam, lParam));
  12.          case WM_COMMAND:
  13.                switch ( LOWORD( wParam ) )
  14.                {
  15.                      case IDM_TEST:
  16.                      {
  17.                            TIME_ZONE_INFORMATION tziLocal;
  18.                            DWORD                 dwTimeZoneMode;
  19.                            TCHAR                 szBuffer[128];
  20.  
  21.                            dwTimeZoneMode = GetTimeZoneInformation( &tziLocal );
  22.  
  23.                            if ( dwTimeZoneMode == TIME_ZONE_ID_STANDARD )
  24.                               wsprintf( szBuffer,
  25.                                         "Time Zone Name: %sST, Bias: %d",
  26.                                         tziLocal.StandardName,
  27.                                         tziLocal.Bias + tziLocal.StandardBias );
  28.                            else
  29.                               wsprintf( szBuffer,
  30.                                         "Time Zone Name: %sDT, Bias: %d",
  31.                                         tziLocal.DaylightName,
  32.                                         tziLocal.Bias + tziLocal.DaylightBias );
  33.  
  34.                            MessageBox( hWnd, szBuffer, "Time Zone Data", MB_OK );
  35.  
  36.                            // Change time zone data. Add 60 minutes to Bias.
  37.                            tziLocal.Bias += 60;
  38.                            SetTimeZoneInformation( &tziLocal );
  39.  
  40.                      }
  41.                      break;
  42.                      case IDM_EXIT:
  43.                            DestroyWindow( hWnd );
  44.                            break;
  45.                }
  46.                break;
  47.                case WM_DESTROY:
  48.                      SetTimeZoneInformation( &tziInit );  // Restore time zone data
  49.                      PostQuitMessage( 0 );
  50.                      break;
  51.          default:
  52.                return (DefWindowProc(hWnd, uMsg, wParam, lParam));
  53.    }
  54.    return (NULL);
  55. }
  56.